@model Orchard.ContentTypes.ViewModels.CreateTypeViewModel

@{ Layout.Title = T("New Content Type").ToString(); }

@using (Html.BeginFormAntiForgeryPost()) {
    @Html.ValidationSummary()
    <fieldset>
        <label for="DisplayName">@T("Display Name")</label>
        @Html.TextBoxFor(m => m.DisplayName, new {@class = "textMedium", autofocus = "autofocus"})
        <label for="Name">@T("Content Type Id")</label>
        @Html.TextBoxFor(m => m.Name, new {@class = "text"})
    </fieldset>
    <fieldset>
        <button class="primaryAction" type="submit">@T("Create")</button>
    </fieldset>}

@using(Script.Foot()){
<script type="text/javascript">
//<![CDATA[
    $(function(){
        //pull slug input from tab order
        $("#@Html.FieldIdFor(m=>m.Name)").attr("tabindex",-1);
        $("#@Html.FieldIdFor(m=>m.DisplayName)").blur(function(){
            var name = $("#@Html.FieldIdFor(m=>m.Name)");
            if (name.val()) { return true; }
            var displayName = $("#@Html.FieldIdFor(m=>m.DisplayName)").val();
            jQuery.post(
                "@Url.Action("ContentTypeName","Admin",new RouteValueDictionary{{"Area","Orchard.ContentTypes"}})",
                {
                    displayName: $("#@Html.FieldIdFor(m=>m.DisplayName)").val(),
                    __RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
                },
                function(data) {
                    name.val(data);
                },
                "json"
            );
        })
    })
//]]>
</script>
}